package com.beta.em.order;

import java.util.Objects;

/**
 * Created by lichao on 2016/11/24.
 */
public enum TransactionType {

    PAYOUT("payout", "支付"),
    PAY_FEE("yeepay_fee", "易宝支付手续费"),
    PLATFORM_FEE("platform_fee", "平台手续费"),
    COMPLETE("complete", "已完成"),
    SETTLED("settled", "已结算"),
    REFUND_SETTLED("refund_settled", "退款结算"),
    REFUND_AGREE("refund_agree", "退款确认"),
    PLATFORM_INCOME("self_income", "平台收益");

    private String value;
    private String cnValue;

    TransactionType(String value, String cnValue) {
        this.value = value;
        this.cnValue = cnValue;
    }

    public String getCnValue() {
        return cnValue;
    }

    public String getValue() {
        return value;
    }

    public static TransactionType getTxnType(String value) {
        for (TransactionType orderStatus: values()) {
            if (orderStatus.getValue().equals(value)) {
                return orderStatus;
            }
        }
        return null;
    }

    public static String getCnValue(String value) {
        TransactionType orderStatus = getTxnType(value);
        if (Objects.nonNull(orderStatus)) {
            return orderStatus.getCnValue();
        } else {
            return "";
        }
    }

}